//
//  AddDeviceViewController.m
//  Fantasia
//
//  Created by kongkong on 2016/12/25.
//  Copyright © 2016年 Kongkong. All rights reserved.
//

#import "AddDeviceViewController.h"

@interface AddDeviceViewController ()
@property (nonatomic,strong) UITextField * deviceId;
@property (nonatomic,strong) UITextField * followUserEdit;
@property (nonatomic,strong) UIButton* addDeviceAction;
@property (nonatomic,strong) NSMutableArray* followUserInfos;
@end

@implementation AddDeviceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"添加设备";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self loadContent];
    [self loadData];
    // Do any additional setup after loading the view.
}

- (UITextField *)deviceId {
    if (!_deviceId) {
        _deviceId = [[UITextField alloc] init];
        _deviceId.keyboardType = UIKeyboardTypeASCIICapable;
        _deviceId.keyboardAppearance = UIKeyboardAppearanceDark;
        _deviceId.autocapitalizationType = UITextAutocapitalizationTypeNone;
        _deviceId.autocorrectionType = UITextAutocorrectionTypeNo;
    }
    return _deviceId;
}

-(UITextField *)followUserEdit{
    if (!_followUserEdit) {
        _followUserEdit = [[UITextField alloc] init];
        _followUserEdit.keyboardType = UIKeyboardTypeASCIICapable;
        _followUserEdit.keyboardAppearance = UIKeyboardAppearanceDark;
        _followUserEdit.autocapitalizationType = UITextAutocapitalizationTypeNone;
        _followUserEdit.autocorrectionType = UITextAutocorrectionTypeNo;
    }
    return _followUserEdit;
}

- (UIButton *)addDeviceAction {
    if (!_addDeviceAction) {
        _addDeviceAction = [[UIButton alloc] initWithFrame:CGRectMake(self.view.width / 6, 0, self.view.width / 3 * 2, 35)];
        [_addDeviceAction setTitle:@"添加设备" forState:UIControlStateNormal];
        [_addDeviceAction setBackgroundImage:[UIImage createImageWithColor:[UIColor orangeColor]] forState:UIControlStateNormal];
        [_addDeviceAction setBackgroundImage:[UIImage createImageWithColor:[UIColor lightGrayColor]] forState:UIControlStateHighlighted];
    }
    return _addDeviceAction;
}

- (UILabel *)labelWithText:(NSString *)text frame:(CGRect)frame {
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.textColor = [UIColor grayColor];
    label.font = [UIFont systemFontOfSize:18];
    label.textAlignment = NSTextAlignmentRight;
    return label;
}


- (void)loadContent{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *uidLabel = [self labelWithText:@"设备ID:" frame:CGRectMake(0, 80, self.view.width / 3, 25)];
    [self.view addSubview:uidLabel];
    self.deviceId.frame = CGRectMake(uidLabel.right + 20, uidLabel.top, self.view.width / 3 * 2 - 80, uidLabel.height);
    [self.view addSubview:self.deviceId];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(self.deviceId.left, uidLabel.bottom + 5, self.deviceId.width, 0.5)];
    line.backgroundColor = [UIColor grayColor];
    [self.view addSubview:line];
    
    UILabel *pwdLabel = [self labelWithText:@"归属用户:" frame:CGRectMake(0, uidLabel.bottom + 30, self.view.width / 3, 25)];
    [self.view addSubview:pwdLabel];
    self.followUserEdit.frame = CGRectMake(pwdLabel.right + 20, pwdLabel.top, self.view.width / 3 * 2 - 80, pwdLabel.height);
    [self.view addSubview:self.followUserEdit];
    
    UIView *line2 = [[UIView alloc] initWithFrame:line.frame];
    line2.top = pwdLabel.bottom + 5;
    line2.backgroundColor = [UIColor grayColor];
    [self.view addSubview:line2];
    
    self.addDeviceAction.top = line2.bottom + 30;
    [self.view addSubview:self.addDeviceAction];
    
    [self.addDeviceAction addTarget:self action:@selector(addDevice) forControlEvents:UIControlEventTouchUpInside];

}

- (void)loadData{
    [[KKRequestEngine api:@"user" action:@"FETCHFOLLOWUSER"]
     async:^(id  _Nullable response, id  _Nullable result) {
         
     }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)addDevice{
    
}
@end
